package second.progr.tc;

import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*; 


import org.testng.annotations.Test;

import second.progr.helpstaff.FoldersList;

public class FolderCreationTests extends TestBase{
    
	//@Test(dataProvider = "randomFolderNameGenerator")       
	@Test
	public void testFolderCreation() {
		String foldName = generateRandomString();
		FoldersList oldFoldersList = app.getFolderHelper().getFolders();
		assertThat(app.getFolderHelper().createFolder(foldName), is(nullValue()));
		FoldersList newFoldersList = app.getFolderHelper().getFolders();
		assertThat(newFoldersList, equalTo(oldFoldersList.withAdded(foldName)));
	}
	
	//@Test
	public void testFolderWithSameNameCreation() {
		String foldName = generateRandomString();
		FoldersList oldFoldersList = app.getFolderHelper().getFolders();
		assertThat(app.getFolderHelper().createFolder(foldName), is(nullValue()));
		FoldersList newFoldersList = app.getFolderHelper().getFolders();
		assertThat(newFoldersList, equalTo(oldFoldersList.withAdded(foldName)));
		assertThat(app.getFolderHelper().createFolder(foldName), containsString("Duplicated folder name"));
		FoldersList newFoldersList2 = app.getFolderHelper().getFolders();
		assertThat(newFoldersList2, equalTo(newFoldersList));
	}
	
	//@Test
	public void testFolderWithVariousFolderCreation() {
		String foldName1 = generateRandomString();
		String foldName2 =  generateRandomString();
		FoldersList oldFoldersList = app.getFolderHelper().getFolders();
		assertThat(app.getFolderHelper().createFolder(foldName1), is(nullValue()));
		FoldersList newFoldersList = app.getFolderHelper().getFolders();
		assertThat(newFoldersList, equalTo(oldFoldersList.withAdded(foldName1)));
		assertThat(app.getFolderHelper().createFolder(foldName2), is(nullValue()));
		FoldersList newFoldersList2 = app.getFolderHelper().getFolders();
		assertThat(newFoldersList2, equalTo(newFoldersList.withAdded(foldName2)));
	}
}
